package com.smile.controller;

import cn.dev33.satoken.annotation.SaIgnore;
import cn.dev33.satoken.filter.SaFirewallCheckFilterForServlet;
import cn.dev33.satoken.stp.StpUtil;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjectUtil;
import com.dtflys.forest.annotation.Get;
import com.smile.api.OrganizationApi;
import com.smile.commons.page.R;
import com.smile.commons.tree.TreeNode;
import com.smile.model.request.*;
import com.smile.model.response.GetOrganizationByIdResponse;
import com.smile.model.response.GetOrganizationByIdsResponse;
import com.smile.model.response.GetOrganizationListResponse;
//import com.smile.model.response.response.GetOrganizationByIdResponseDTO;
//import com.smile.model.response.response.GetOrganizationByIdsResponseDTO;
//import com.smile.model.response.response.GetOrganizationListResponseDTO;
//import com.smile.service.OrganizationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@RestController
@RequestMapping("/organization")
@Validated
@CrossOrigin
public class OrganizationController {

    @Autowired
    private OrganizationApi organizationApi;
    @Autowired
    private SaFirewallCheckFilterForServlet saFirewallCheckFilterForServlet;




    /**
     * 获取组织列表
     *
     * @param getOrganizationListRequest
     * @return
     */
    @RequestMapping(value = "/getDeviceList", produces = MediaType.APPLICATION_JSON_VALUE, method = {RequestMethod.POST})
    public R<List<GetOrganizationListResponse>> getDeviceList(@RequestBody GetOrganizationListRequest getOrganizationListRequest) {
        R<List<GetOrganizationListResponse>> list = organizationApi.getDeviceList(getOrganizationListRequest);
        return list;
    }

    /**
     * 获取组织列表
     *
     * @param getOrganizationListRequest
     * @return
     */
    @RequestMapping(value = "/list", produces = MediaType.APPLICATION_JSON_VALUE, method = {RequestMethod.POST})
    public R<List<GetOrganizationListResponse>> getOrganizationList(@RequestBody GetOrganizationListRequest getOrganizationListRequest) {
        R<List<GetOrganizationListResponse>> list = organizationApi.list(getOrganizationListRequest);
        return list;
    }

}
